﻿@using Model.WeiXin;
@using Xproject.Util;
@{               
string Domain = CommonHelper.GetAppSettings("Domin");
Layout = "~/Views/Shared/_JSlayout.cshtml";
}
@model WeiXinUser
<div class="gray-bg">
    <div class="  animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>@ViewBag.Title</h5>
                    </div>
                    <div class="ibox-content">
                        <form class="form-horizontal m-t" id="WXUserForm" action="~/WXUser/EditWXUser" method="post">

                            <div class="form-group">
                                <label class="col-sm-2 control-label">用户code：</label>
                                <div class="col-sm-2">
                                    <input id="UserCode" name="UserCode" disabled="disabled" class="form-control" type="text" required min="4" value="@(Model!=null?Model.UserCode:"")">
                                </div>
                                <label class="col-sm-2 control-label">用户等级：</label>
                                <div class="col-sm-2">
                                    <input id="GradeID" name="GradeID" class="form-control" type="text" required min="4" value="@(Model!=null?Model.GradeID:0)">
                                </div>
                                <label class="col-sm-2 control-label">昵称：</label>
                                <div class="col-sm-2">
                                    @if (Model != null)
    {
                                <input id="NickName" name="NickName" disabled="disabled" class="form-control" type="text" required min="4" value="@(Model != null ? Model.NickName : "")">
}
else
{
                                <input id="NickName" name="NickName"   class="form-control" type="text" required >
}

                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">关注时间：</label>
                                <div class="col-sm-2">
                                    <input type="text" class="form-control" disabled="disabled" name="FocusTime" id="FocusTime" placeholder="" required value="@(Model!=null?Model.FocusTime.Value.ToString("yyyy-MM-dd HH:mm:ss"):"")" />
                                </div>
                                <label class="col-sm-2 control-label">创建时间：</label>
                                <div class="col-sm-2">
                                    <input type="text" class="form-control" disabled="disabled" name="CreateTime" id="CreateTime" placeholder="" required value="@(Model!=null?Model.CreateTime.Value.ToString("yyyy-MM-dd HH:mm:ss"):"")" />
                                </div>
                                <label class="col-sm-2 control-label">手机：</label>
                                <div class="col-sm-2">
                                    <input id="Mobile" name="Mobile" class="form-control" type="number" aria-required="true" aria-invalid="false" class="valid" value="@(Model!=null?Model.Mobile:"")" required>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-3 control-label">重置登录密码：</label>
                                <div class="col-sm-8">
                                    <input type="password" class="form-control" name="Password" id="Password" placeholder="请输入密码"  />
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">确认密码：</label>
                                <div class="col-sm-8">
                                    <input type="password" class="form-control" name="ComfirmPassword" id="ComfirmPassword" placeholder="请输入密码" />
                                </div>
                            </div>


                            <div class="form-group">
                                <label class="col-sm-2 control-label">头像图</label>
                                <div class="col-sm-4">
                                    <input id="productContentImg" name="productContentImg" class="form-control" type="file">
                                    @if (Model != null)
    {
                                <img id="img" src="@(Model != null ? Model.HeadUrl : "")" style="width:200px;height:160px;">
}
else
{
                                <img id="img" src="" style="width:200px;height:160px;display:none">
}

                                    <input id="hiddenIndex" value="" type="hidden" />
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-8 col-sm-offset-3">
                                    @if (Model != null)
            {
                        <input type="hidden" name="ID" value="@Model.UserID" />
}
                                    <button class="btn btn-primary" type="submit">提交</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- 全局js -->

<script type="text/javascript">
    $(document).ready(function () {
        var optionsNew = {
            beforeSubmit: function () {
                //layer.open({ type: 2, time: 2 });
                layer.load(1, { shade: [0.1, '#000'], time: 2000 });
            },
            success: function (data) {
                if (data.Success == true) {
                    layer.alert('编辑成功', { icon: 1, skin: 'layer-ext-moon', time: 2000 });
                } else {
                    layer.alert(data.Data, { icon: 1, skin: 'layer-ext-moon', time: 2000 });
                }
            },
            error: function () {
                alert(JSON.stringify(data));
            },
            type: "post",
            clearForm: false,
            timeout: 100000
        };

        $("#WXUserForm").submit(function () {
            $("#WXUserForm").ajaxSubmit(optionsNew);// type="button"
            return false;
        });
    });

    $("#productContentImg").on("change", function () {
        var file = this.files[0];
        if (this.files && file) {
            var reader = new FileReader();
            reader.onload = function (e) {
                $("#img").attr("src", e.target.result);
                $("#img").show();
            }
            reader.readAsDataURL(file);
        }
    });
</script>


